package com.lj.queue.handler;

import cn.hutool.core.util.ClassUtil;
import cn.hutool.json.JSONUtil;

/**
 * @author luojing
 * @since 2025/7/18 11:40
 */
public abstract class AbstractHandler<M> implements DelayMessageHandler<M> {

    private final Class<M> messageType = (Class<M>) ClassUtil.getTypeArgument(this.getClass());

    @Override
    public M convertMessage(DelayHandlerContext handlerContext) throws Exception {
        return JSONUtil.toBean(handlerContext.getMessage(), messageType);
    }
}
